package com.minelx.scriptbuilder.script.attribute.clazz;

import com.minelx.scriptbuilder.parse.annotation.Clazz;
import com.minelx.scriptbuilder.parse.annotation.Method;
import com.minelx.scriptbuilder.script.attribute.function.Params;
import com.minelx.scriptbuilder.script.attribute.value.IAttribute;
import com.minelx.scriptbuilder.script.attribute.value.IntValue;

@Clazz(className = "String")
public class StringClass extends Class {
	@Method
	public IAttribute init(Params params) {
		IAttribute self = params.at(0).value();
		IAttribute stringValue = params.at(1).value();
		self.set("value", stringValue);
		self.set("length", new IntValue(stringValue.asString().length()));
		return IAttribute.nil();
	}

	@Method
	public IAttribute asString(Params params) {
		return params.at(0).value().value("value");
	}
}
